import QQMapWX from './map/qqmap-wx-jssdk'
export default {
	reverseGeocoder(latitude, longitude) {
		const qqmapsdk = new QQMapWX({
			key: 'BJ6BZ-VVTEF-RZGJG-JZL34-HVOV7-52BDP'
		});
		return new Promise((resolve, reject) => {
			qqmapsdk.reverseGeocoder({
				location: {
					latitude: latitude,
					longitude: longitude
				},
				success: (res) => {
					resolve(res);
				},
				fail: (err) => {
					reject(err)
				}
			});
		})
	},
	geocoder(address) {
		const qqMap = new QQMapWX({
			key: 'BJ6BZ-VVTEF-RZGJG-JZL34-HVOV7-52BDP'
		});
		return new Promise((resolve, reject) => {
			qqMap.geocoder({
				address,
				success: (res) => {
					resolve(res);
				},
				fail: (err) => {
					reject(err)
				}
			});
		})
	},
	direction(options) {
		const qqMap = new QQMapWX({
			key: 'BJ6BZ-VVTEF-RZGJG-JZL34-HVOV7-52BDP'
		});
		return new Promise((resolve, reject) => {
			qqMap.direction({
				...options,
				success: (res) => {
					resolve(res);
				},
				fail: (err) => {
					reject(err)
				}
			});
		})
	}
}